#include "utills.h"

void makeIDent(std::ostream &stream, int ident)
{
    for(int i = 0; i < ident; ++i)
        stream << "    ";
}

SetOfChars::Range SetOfChars::makeNormal(char ch1, char ch2)
{
    return ch1 > ch2 ? std::make_pair(ch2, ch1): std::make_pair(ch1, ch2);
}

SetOfChars &SetOfChars::operator()(char ch)
{
    singles_.push_back(ch);
    return *this;
}
SetOfChars &SetOfChars::operator()(char ch1, char ch2)
{
    ranges_.push_back(SetOfChars::makeNormal(ch1, ch2));
    return *this;
}
bool SetOfChars::in(char ch)
{
    for(std::list<Range>::iterator i = ranges_.begin(); i != ranges_.end(); ++i)
        if(i->first <= ch && i->second >= ch) return true;
    for(std::list<char>::iterator i = singles_.begin(); i != singles_.end(); ++i)
        if(*i == ch) return true;
    return false;
}
